Constructs a BTreeList instance.
Syntax
Example
Library/Library.Test/TestBTreeDictionary.cs
C# | Copy Code |
---|
List<KeyValuePair<int, string>> sample = new List<KeyValuePair<int,string>>(GetSample());
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(sample);
//Key collection
Assert.AreEqual(data.Count, data.Keys.Count);
Assert.IsTrue(data.Keys.IsReadOnly);
for (int i = 0; i < sample.Count && i < 5; i++)
Assert.IsTrue(data.Keys.Contains(sample[i].Key));
IEnumerator<int> ek = data.Keys.GetEnumerator();
Assert.IsTrue(ek.MoveNext());
int firstkey = ek.Current;
Assert.IsTrue(ek.MoveNext());
Assert.AreNotEqual(firstkey, ek.Current);
ek.Reset();
Assert.IsTrue(ek.MoveNext());
Assert.AreEqual(firstkey, ek.Current);
Assert.AreEqual(firstkey, ((System.Collections.IEnumerator)ek).Current);
//Value collection
Assert.AreEqual(data.Count, data.Values.Count);
Assert.IsTrue(data.Values.IsReadOnly);
for (int i = 0; i < sample.Count && i < 5; i++)
Assert.IsTrue(data.Values.Contains(sample[i].Value));
IEnumerator<string> ev = data.Values.GetEnumerator();
Assert.IsTrue(ev.MoveNext());
string firstvalue = ev.Current;
Assert.IsTrue(ev.MoveNext());
Assert.AreNotEqual(firstvalue, ev.Current);
ev.Reset();
Assert.IsTrue(ev.MoveNext());
Assert.AreEqual(firstvalue, ((System.Collections.IEnumerator)ev).Current); |
VB.NET | Copy Code |
---|
Dim sample As New List(Of KeyValuePair(Of Integer, String))(GetSample())
Dim data As New BTreeDictionary(Of Integer, String)(sample)
'Key collection
Assert.AreEqual(data.Count, data.Keys.Count)
Assert.IsTrue(data.Keys.IsReadOnly)
Dim i As Integer = 0
While i < sample.Count AndAlso i < 5
Assert.IsTrue(data.Keys.Contains(sample(i).Key))
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Dim ek As IEnumerator(Of Integer) = data.Keys.GetEnumerator()
Assert.IsTrue(ek.MoveNext())
Dim firstkey As Integer = ek.Current
Assert.IsTrue(ek.MoveNext())
Assert.AreNotEqual(firstkey, ek.Current)
ek.Reset()
Assert.IsTrue(ek.MoveNext())
Assert.AreEqual(firstkey, ek.Current)
Assert.AreEqual(firstkey, (DirectCast(ek, System.Collections.IEnumerator)).Current)
'Value collection
Assert.AreEqual(data.Count, data.Values.Count)
Assert.IsTrue(data.Values.IsReadOnly)
Dim i As Integer = 0
While i < sample.Count AndAlso i < 5
Assert.IsTrue(data.Values.Contains(sample(i).Value))
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Dim ev As IEnumerator(Of String) = data.Values.GetEnumerator()
Assert.IsTrue(ev.MoveNext())
Dim firstvalue As String = ev.Current
Assert.IsTrue(ev.MoveNext())
Assert.AreNotEqual(firstvalue, ev.Current)
ev.Reset()
Assert.IsTrue(ev.MoveNext())
Assert.AreEqual(firstvalue, (DirectCast(ev, System.Collections.IEnumerator)).Current) |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also